'''
Created on 2017年4月4日

@author: Administrator
'''
#map
from _functools import reduce
def f(x):
    return x*x
#map(函数名，需要操作的值列表)
l = map(f,[1,2,3,4,5,6,7,8,9])

for a in l:
    print(a)
    
#reduce示例-转换字串为整数    
def fn(x, y):
    return x * 10 + y
def char2num(s):
    return {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}[s]
print(reduce(fn, map(char2num, '13579')))

